import { onMounted, onUnmounted } from 'vue'
/**
 *@description  注册事件
 * @param dom   目标 dom
 * @param event 事件类型
 * @param cb    事件回调
 * @param options
 */
export function useEventListener(
	dom: HTMLElement | Window,
	event: keyof WindowEventMap,
	cb: (this: Window, ev: Event) => any,
	options?: AddEventListenerOptions
) {
	onMounted(() => dom.addEventListener(event, cb, options))
	onUnmounted(() => dom.removeEventListener(event, cb, options))
}
